package com.xc.dao;

import com.xc.pojo.Permission;
import com.xc.vo.PermissionVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PermissionMapper {
    /**
     * 查询菜单列表
     * @param permissionVo
     * @return
     */
    List<Permission> queryPermissionList(PermissionVo permissionVo);

    /**
     * 添加菜单
     * @return
     */
    int addMenu(Permission permission);
    /**
     * 修改菜单
     * @return
     */
    int updateMenu(Permission permission);

    /**
     * 检查菜单下是否有子菜单
     * @param id
     * @return
     */
    @Select("select count(1) from sys_permission where pid = #{id}")
    int queryPermissionCountById(Integer id);
    /**
     * 删除菜单
     * @param id
     * @return
     */
    @Delete("delete from sys_permission where id = #{id}")
    int deleteById(Integer id);


    /**
     * 根据当前登录用户查询菜单列表
     * @param userId
     * @return
     */
    List<Permission> findPermissionListByUserId(@Param("userId") Integer userId, @Param("type") String type);

}
